import React, { useEffect } from "react";
import "./index.less";

interface IProps {
  rsourceData: string | string[];
  onCon?: (str: string) => void;
  onRender?: (isForce?: boolean) => void;
}

const RecommendQues: React.FC<IProps> = ({ rsourceData, onRender, onCon }) => {
  useEffect(() => {
    onRender && onRender(true);
  }, []);
  return (
    <>
      {typeof rsourceData === "string" ? (
        <div
          className={`chat-recommend-ques ${onCon ? "chat-recommend-ques-click" : ""}`}
          onClick={() => {
            onCon && onCon(rsourceData);
          }}
        >
          {rsourceData}
        </div>
      ) : (
        rsourceData.map((item, index) => {
          return (
            <div
              key={index}
              className={`chat-recommend-ques ${onCon ? "chat-recommend-ques-click" : ""}`}
              onClick={() => {
                onCon && onCon(item);
              }}
            >
              {item}
            </div>
          );
        })
      )}
    </>
  );
};

export default RecommendQues;
